# # 生产海报
# import uuid
# from tortoise import fields, models
# from tortoise.contrib.pydantic import pydantic_model_creator
# from datetime import datetime, timedelta

# from models.user import User
# from models.products import Product

# class Distributor(models.Model):
#     """分销人员模型"""
#     # 主键（使用UUID替代自增ID，增强安全性）
#     id = fields.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
#     user = fields.OneToOneField('models.User', on_delete=fields.CASCADE,related_name='distributor_profile',verbose_name='关联用户')
#     parent = fields.ForeignKeyField('models.Distributor',on_delete=fields.SET_NULL,null=True,blank=True,related_name='sub_distributors',verbose_name='上级分销商（树形结构，允许为空表示顶级分销商）')
#     level = fields.IntField(default=0, verbose_name='分销层级(表示当前人员在树中的深度，顶级为0）')
#     total_commission = fields.DecimalField( max_digits=10,decimal_places=2,default=0.0,verbose_name='累计佣金')
#     withdrawable_commission = fields.DecimalField(max_digits=10,decimal_places=2,default=0.0,verbose_name='可提现佣金（未提现部分）')
#     referral_code = fields.CharField(max_length=255,unique=True,verbose_name='分销代码（唯一标识，用于分享链接）')
#     join_time = fields.DatetimeField(auto_now_add=True, verbose_name='加入时间')
#     is_active = fields.BooleanField(default=True, verbose_name='是否活跃')

#     class Meta:
#         table = "distributors"

# class PosterTemplate(models.Model):
#     """海报模板模型"""
#     id = fields.UUIDField(pk=True, default=uuid.uuid4)
#     name = fields.CharField(max_length=100, description="海报模板名称") 
#     background_image = fields.CharField(max_length=255, description="背景图URL")  
#     width = fields.IntField(default=600, description="宽度(px)" )
#     height = fields.IntField(default=800, description="高度(px)")  
#     is_active = fields.BooleanField(default=True, description="是否激活")
#     created_at = fields.DatetimeField(auto_now_add=True)
    
#     class Meta:
#         table = "poster_templates"


# class GeneratedPoster(models.Model):
#     """生成的海报模型"""
#     id = fields.UUIDField(pk=True, default=uuid.uuid4)
#     user = fields.ForeignKeyField("models.User", related_name="posters")
#     product = fields.ForeignKeyField("models.Product", related_name="posters")
#     template = fields.ForeignKeyField("models.PosterTemplate", related_name="generated_posters")
#     title = fields.CharField(max_length=200, description="海报标题")
#     qr_code_url = fields.CharField(max_length=255, description="二维码图片URL") 
#     qr_code_content = fields.CharField(max_length=255, description="二维码内容")  
#     poster_image_url = fields.CharField(max_length=255, description="生成的海报URL")  
#     share_count = fields.IntField(default=0, description="分享次数")
#     view_count = fields.IntField(default=0, description="浏览次数")
#     click_count = fields.IntField(default=0, description="点击次数")
#     is_valid = fields.BooleanField(default=True, description="是否有效")
#     created_at = fields.DatetimeField(auto_now_add=True, description="创建时间")
#     expired_at = fields.DatetimeField(default=lambda: datetime.now() + timedelta(days=30), description="过期时间")

#     class Meta:

#         table = "generated_posters"

# # Pydantic模型用于API交互
# User_Pydantic = pydantic_model_creator(User, name="User")
# Product_Pydantic = pydantic_model_creator(Product, name="Product")
# GeneratedPoster_Pydantic = pydantic_model_creator(GeneratedPoster, name="GeneratedPoster")